﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using DBBase;
using System.Threading;
using System.Xml;


using System.Web;

using System.Runtime.InteropServices;
using System.IO;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Xml.Linq;


namespace Business
{
    public partial class Audit_Management : Form
    {
        private Button btn = new Button();
        private Button btn2 = new Button();
        public Audit_Management()
        {
            InitializeComponent();
            getjilu();
        }
        private void button_Click(object sender, EventArgs e)
        {
            MessageBox.Show(this.lv.SelectedItems[0].SubItems[0].Text);
        }
        private void button_Click2(object sender, EventArgs e)
        {
            MessageBox.Show(this.lv.SelectedItems[0].SubItems[0].Text);
        }
        public void getjilu()
        {
            

                lv.Items.Clear();   
            Query mquery = new Query();
            string sql;
            sql = string.Format(@"Select * from ziyuankongzhi ");

            sql = sql + " order by zykz_id  ";
            //try
            {
                DataTable dt = mquery.GetTable(sql);

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {


                        ListViewItem lt = new ListViewItem(string.Format(@"{0}",i+1));
                        lt.SubItems.Add(dt.Rows[i]["xsname"].ToString().Trim());
                        lt.SubItems.Add(dt.Rows[i]["username"].ToString().Trim());
                        lt.SubItems.Add(dt.Rows[i]["keyzhi"].ToString().Trim());
                        lt.SubItems.Add(dt.Rows[i]["beizhu"].ToString().Trim());
                        lt.SubItems.Add(dt.Rows[i]["zhuangtai"].ToString().Trim());

                        lt.SubItems.Add("关闭");
                        lt.SubItems.Add("修改");

                        this.lv.Items.Add(lt);

                        btn.Visible = false;
                        //btn.Text = "关闭";
                        //btn.Click += this.button_Click;
                        //this.lv.Controls.Add(btn);
                        //this.btn.Size = new Size(75,
                        //20);


                        btn2.Visible = false;
                        //btn2.Text = "修改";
                        //btn2.Click += this.button_Click2;
                        //this.lv.Controls.Add(btn2);
                        //this.btn2.Size = new Size(75,
                        //20);  
                    }
                }
               

            }

        }

        private void lv_SelectedIndexChanged(object sender, EventArgs e)
        {
            //if (this.lv.SelectedItems.Count > 0)
            //{
            //    this.btn.Location = new Point(this.lv.SelectedItems[0].SubItems[6].Bounds.Left,
            //        this.lv.SelectedItems[0].SubItems[6].Bounds.Top);
            //    this.btn.Visible = true;

            //    this.btn2.Location = new Point(this.lv.SelectedItems[0].SubItems[7].Bounds.Left,
            //       this.lv.SelectedItems[0].SubItems[7].Bounds.Top);
            //    this.btn2.Visible = true;
            //}  
        }

       
    }
}
